package cn.wdm.ymcc.feign;

import cn.wdm.ymcc.CourseDoc;
import cn.wdm.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class SearchFeignClientFallBackFactory implements FallbackFactory<SearchFeignClient> {
    @Override
    public SearchFeignClient create(Throwable throwable) {
        return new SearchFeignClient() {
            @Override
            public JSONResult savaCourse2Es(CourseDoc doc) {
                throwable.printStackTrace();
                return JSONResult.error("请求不到Es搜索服务");
            }
            @Override
            public JSONResult deleteCourseInEs(Long courseId) {
                throwable.printStackTrace();
                return JSONResult.error("请求不到Es搜索服务");
            }
        };
    }
}
